/* 基础样式 */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 聊天界面容器 */
.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: white;
}

/* 头部样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.header h1 {
    margin: 0;
    font-size: 1.2em;
    color: #333;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.icon-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.icon-button .material-icons {
    font-size: 20px;
    color: #666;
}

/* 聊天区域 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    height: 100%;
}

/* 消息列表容器 */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 180px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    height: calc(100vh - 50px);
    box-sizing: border-box;
}

.message {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transition: opacity 0.2s ease-in-out;
    margin-bottom: 12px;
}

.message:last-child {
    margin-bottom: 30px;
}

.message pre {
    margin: 10px 0;
    padding: 0;
    background: none;
}

.message pre code {
    display: block;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    background-color: #f6f8fa;
    overflow-x: auto;
}

.message code.inline-code {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    background-color: #f6f8fa;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

.message.user {
    background-color: #007bff;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background-color: #f1f3f5;
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    white-space: pre-wrap;
}

.message.assistant.error {
    background-color: #fee;
    color: #c00;
}

.message.assistant::after {
    content: '▋';
    display: inline-block;
    vertical-align: middle;
    animation: cursor-blink 1s step-start infinite;
}

.message.assistant.done::after {
    display: none;
}

@keyframes cursor-blink {
    50% { opacity: 0; }
}

/* 输入区域 */
.input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 15px;
    border-top: 1px solid #ddd;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
    max-height: 200px;
}

.input-wrapper {
    display: flex;
    gap: 8px;
}

#message-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    resize: none;
    height: 36px;
    font-size: 14px;
    line-height: 1.4;
}

#message-input:focus {
    outline: none;
    border-color: #007bff;
}

.buttons {
    display: flex;
    gap: 8px;
}

#send-message {
    padding: 0 16px;
    height: 36px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

#send-message:hover {
    background-color: #0056b3;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 其它样式 */
.sidepanel {
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}

.sidepanel .container {
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.settings {
    padding: 10px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    z-index: 2;
}

#api-key {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#save-key {
    padding: 8px 15px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.code-block {
    position: relative;
    margin: 10px 0;
    background: #282c34;
    border-radius: 8px;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code-language {
    color: #abb2bf;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.copy-button {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #abb2bf;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.copy-button.copied {
    background: #98c379;
    border-color: #98c379;
    color: #282c34;
}

.copy-icon {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.copy-button:hover .copy-icon {
    opacity: 1;
}

.code-block pre {
    margin: 0;
    padding: 12px;
}

.user-message .code-block {
    background: rgba(0, 0, 0, 0.3);
}

.user-message .code-header {
    background: rgba(255, 255, 255, 0.1);
}

.user-message .copy-button {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.user-message .copy-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.user-message .code-language {
    color: #fff;
}

.message img {
    max-width: 200px;
    border-radius: 8px;
    margin: 5px 0;
}

.error-message {
    background-color: #ffebee;
    color: #c62828;
    border-left: 4px solid #c62828;
    padding: 10px;
    margin: 5px 0;
    border-radius: 4px;
    align-self: center;
    max-width: 90%;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    margin: 0 auto;
}

pre {
    margin: 10px 0;
    padding: 0;
    background: transparent;
}

code {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.4;
}

pre code {
    display: block;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    background: #282c34;
    color: #abb2bf;
}

:not(pre) > code {
    padding: 2px 5px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.1);
    color: inherit;
}

.user-message pre code {
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
}

@media (max-width: 480px) {
    .copy-text {
        display: none;
    }
    
    .copy-button {
        padding: 4px;
    }
}

/* 确保滚动条样式美观 */
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #666;
}
